package com.atguigu.gmall.pay.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2025/9/15 20:25
 */
@EnableConfigurationProperties(AlipayProperties.class)
@Configuration
public class AlipayConfig {
    @Bean
    public AlipayClient alipayClient(AlipayProperties alipayProperties) throws Exception {

        return new DefaultAlipayClient(alipayProperties.getGatewayUrl(),alipayProperties.getApp_id(), alipayProperties.getMerchant_private_key(), "json", alipayProperties.getCharset(), alipayProperties.getAlipay_public_key(),alipayProperties.getSign_type());
    }
}
